package routes

import (
	"github.com/gin-gonic/gin"
	"go-project/controller/admin"
	"go-project/dto/requrest/validate"
	"net/http"
)

func AdminInitRoute(r *gin.Engine) {
	validate.Register()
	adminRouterGroup := r.Group("/admin")
	{
		//admin.Use(authz.NewAuthorizer(casbin.Enforcer))
		adminRouterGroup.GET("/", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "site.index", nil)
		})
		adminRouterGroup.GET("/login", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "login/login.html", nil)
		})
		//adminRouterGroup.POST("/login", admin.AdminController{}.Login)
		adminRouterGroup.GET("/register", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "login/register.html", nil)
		})
		//adminRouterGroup.POST("/register", admin.AdminController{}.Register)
		adminRouterGroup.GET("/welcome", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "site.welcome", nil)
		})
		adminRouterGroup.GET("/admin/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "admin.list", nil)
		})

		adminRouterGroup.GET("/admin/list-data", admin.AdminController{}.List)
		adminRouterGroup.GET("/admin/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "admin.add", nil)
		})
		adminRouterGroup.GET("/admin/edit", admin.AdminController{}.Edit)
		adminRouterGroup.POST("/admin/add", admin.AdminController{}.Add)
		adminRouterGroup.POST("/admin/update", admin.AdminController{}.Update)
		adminRouterGroup.DELETE("/admin/del", admin.AdminController{}.Delete)
		adminRouterGroup.DELETE("/admin/batch-del", admin.AdminController{}.BatchDelete)
		adminRouterGroup.GET("/admin/distribute-role", admin.AdminController{}.DistributeRole)
		adminRouterGroup.POST("/admin/distribute-role", admin.AdminController{}.DistributeRole)
		adminRouterGroup.GET("/article-category/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "article-category.list", nil)
		})
		adminRouterGroup.GET("/article-category/list-data", admin.ArticleCategoryController{}.List)
		adminRouterGroup.GET("/article-category/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "article-category.add", nil)
		})
		adminRouterGroup.POST("/article-category/add", admin.ArticleCategoryController{}.Add)

		adminRouterGroup.GET("/article-category/edit", admin.ArticleCategoryController{}.Edit)
		adminRouterGroup.POST("/article-category/update", admin.ArticleCategoryController{}.Update)
		adminRouterGroup.DELETE("/article-category/del", admin.ArticleCategoryController{}.Delete)

		adminRouterGroup.DELETE("/article-category/batch-del", admin.ArticleCategoryController{}.BatchDelete)

		adminRouterGroup.GET("/article/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "article.list", nil)
		})
		adminRouterGroup.GET("/article/list-data", admin.ArticleController{}.List)
		adminRouterGroup.GET("/article/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "article.add", nil)
		})
		adminRouterGroup.POST("/article/add", admin.ArticleController{}.Add)
		adminRouterGroup.DELETE("/article/del", admin.ArticleController{}.Del)
		adminRouterGroup.DELETE("/article/batch-del", admin.ArticleController{}.BatchDelete)
		adminRouterGroup.GET("/article/edit", admin.ArticleController{}.Edit)
		adminRouterGroup.POST("/article/update", admin.ArticleController{}.Update)

		adminRouterGroup.GET("/tag/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "tag.list", nil)
		})
		adminRouterGroup.GET("/tag/list-data", admin.TagController{}.List)
		adminRouterGroup.GET("/tag/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "tag.add", nil)
		})
		adminRouterGroup.POST("/tag/add", admin.TagController{}.Add)

		adminRouterGroup.GET("/tag/edit", admin.TagController{}.Edit)
		adminRouterGroup.POST("/tag/update", admin.TagController{}.Update)
		adminRouterGroup.DELETE("/tag/del", admin.TagController{}.Delete)

		adminRouterGroup.DELETE("/tag/batch-del", admin.TagController{}.BatchDelete)

		adminRouterGroup.GET("/permissions/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "permissions.list", nil)
		})
		adminRouterGroup.GET("/permissions/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "permissions.add", nil)
		})
		adminRouterGroup.GET("/permissions/list-data", admin.PermissionsController{}.List)
		adminRouterGroup.POST("/permissions/add", admin.PermissionsController{}.Add)
		adminRouterGroup.GET("/permissions/list-tree", admin.PermissionsController{}.ListData)

		adminRouterGroup.GET("/permissions/edit", admin.PermissionsController{}.Edit)
		adminRouterGroup.POST("/permissions/update", admin.PermissionsController{}.Update)
		adminRouterGroup.DELETE("/permissions/del", admin.PermissionsController{}.Delete)

		adminRouterGroup.GET("/roles/list", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "roles.list", nil)
		})
		adminRouterGroup.GET("/roles/list-data", admin.RolesController{}.List)
		adminRouterGroup.GET("/roles/add", func(ctx *gin.Context) {
			ctx.HTML(http.StatusOK, "roles.add", nil)
		})
		adminRouterGroup.POST("/roles/add", admin.RolesController{}.Add)

		adminRouterGroup.GET("/roles/edit", admin.RolesController{}.Edit)
		adminRouterGroup.POST("/roles/update", admin.RolesController{}.Update)
		adminRouterGroup.DELETE("/roles/del", admin.RolesController{}.Delete)

		adminRouterGroup.DELETE("/roles/batch-del", admin.RolesController{}.BatchDelete)
		adminRouterGroup.GET("/roles/auth", admin.RolesController{}.GetAuth)
		adminRouterGroup.POST("/roles/auth", admin.RolesController{}.AuthPermissions)
		adminRouterGroup.GET("/roles/select-get-list", admin.RolesController{}.SelectGetList)

		adminRouterGroup.GET("/system/setting", admin.SystemController{}.Setting)
		adminRouterGroup.GET("/system/site-setting", admin.SystemController{}.SiteSetting)

		adminRouterGroup.GET("/article-comment/list", func(context *gin.Context) {
			context.HTML(http.StatusOK, "article-comment.list", nil)
		})
		adminRouterGroup.POST("/article-comment/list-data", admin.ArticleCommentController{}.List)
		adminRouterGroup.POST("/article-comment/banned", admin.ArticleCommentController{}.Banned)
		adminRouterGroup.GET("/official-account/setting", admin.OfficialAccountController{}.Setting)
		adminRouterGroup.POST("/official-account/setting", admin.OfficialAccountController{}.Setting)
		adminRouterGroup.GET("/official-account/menus", admin.OfficialAccountController{}.Menus)

	}
}
